package com.vctgo.demo.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.vctgo.demo.mapper.ClientMapper;
import com.vctgo.demo.domain.Client;
import com.vctgo.demo.service.IClientService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.vctgo.common.core.text.Convert;
import com.vctgo.common.core.utils.ServletUtils;
import com.vctgo.common.mybatisplus.constant.MybatisPageConstants;
/**
 * 客户Service业务层处理
 *
 * @author vctgo
 * @date 2024-12-18
 */
@Service
public class ClientServiceImpl implements IClientService
{
    @Autowired
    private ClientMapper clientMapper;

    /**
     * 查询客户
     *
     * @param id 客户主键
     * @return 客户
     */
    @Override
    public Client selectClientById(Long id)
    {
        return clientMapper.selectById(id);
    }

    /**
     * 查询客户列表-分页
     *
     * @param client 客户
     * @return 客户
     */
    @Override
    public IPage<Client> selectClientPage(Client client)
    {
        Page mpPage =new Page(Convert.toLong(ServletUtils.getParameterToInt(MybatisPageConstants.PAGE_NUM),1L)
                ,Convert.toLong(ServletUtils.getParameterToInt(MybatisPageConstants.PAGE_SIZE),10L));
        return clientMapper.selectClientList(mpPage,client);
    }
    /**
     * 查询客户列表
     *
     * @param client 客户
     * @return 客户
     */
    @Override
    public List<Client> selectClientList(Client client)
    {
        return clientMapper.selectClientList(client);
    }

    /**
     * 新增客户
     *
     * @param client 客户
     * @return 结果
     */

    @Override
    public int insertClient(Client client)
    {
        return clientMapper.insert(client);
    }

    /**
     * 修改客户
     *
     * @param client 客户
     * @return 结果
     */
    @Override
    public int updateClient(Client client)
    {
        return clientMapper.updateById(client);
    }

    /**
     * 批量删除客户
     *
     * @param ids 需要删除的客户主键
     * @return 结果
     */
    @Override
    public int deleteClientByIds(Long[] ids)
    {
        return clientMapper.deleteClientByIds(ids);
    }

    /**
     * 删除客户信息
     *
     * @param id 客户主键
     * @return 结果
     */
    @Override
    public int deleteClientById(Long id)
    {
        return clientMapper.deleteById(id);
    }
}
